language: node_js
node_js:
  - "0.6"
  - "0.8"
  - "0.10"
  - "0.12"
  - "1.8"
  - "2.5"
  - "3.3"
  - "4.8"
  - "5.12"
  - "6.13"
  - "7.10"
  - "8.9"
  - "9.6"
sudo: false
dist: precise
cache:
  directories:
    - node_modules
before_install:
  # Skip updating shrinkwrap / lock
  - "npm config set shrinkwrap false"
  # Remove all non-test dependencies
  - "npm rm --save-dev benchmark beautify-benchmark"
  # Setup Node.js version-specific dependencies
  - "test $TRAVIS_NODE_VERSION != '0.6' || npm rm --save-dev nyc"
  - "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev nyc"
  - "test $(echo $TRAVIS_NODE_VERSION | cut -d'.' -f1) -ge 4 || npm rm --save-dev eslint eslint-plugin-markdown"
  # Update Node.js modules
  - "test ! -d node_modules || npm prune"
  - "test ! -d node_modules || npm rebuild"
script:
  # Run test script, depending on nyc install
  - "test ! -z $(npm -ps ls nyc) || npm test"
  - "test   -z $(npm -ps ls nyc) || npm run-script test-ci"
  # Run linter
  - "test   -z $(npm -ps ls eslint) || npm run-script lint"
after_script:
  - "test -d .nyc_output && npm install coveralls@2 && nyc report --reporter=text-lcov | coveralls"
